import 'package:flutter/material.dart';
import 'package:flutter_app/utils/log_util.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

///author: create by SunJH
///时间: 2021/12/24 0024
///邮箱: 965989158@qq.com
///描述: inAppWebView测试
///

class InAppWebViewTest extends StatelessWidget {
  InAppWebViewTest({Key? key}) : super(key: key);
  InAppWebViewController? inAppWebViewController;

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: ()async{
        LogUtil.logI("点击了返回按钮");
        // var canGoBack = await inAppWebViewController?.canGoBack()??false;
        // LogUtil.logI(canGoBack);
        // if(canGoBack){
        //   inAppWebViewController?.goBack();
        //   return false;
        // }else{
        //   return true;
        // }
        return true;
      },
      child: MaterialApp(
        home: Scaffold(
          resizeToAvoidBottomInset: false,

          body: SafeArea(
            child: InAppWebView(
              initialUrlRequest: URLRequest(
                  // url: Uri.parse("https://test-c-ks.qimingdaren.com/")),
                  url: Uri.parse("https://www.bilibili.com/")),
              onWebViewCreated: (webViewController) {
                inAppWebViewController = webViewController;
              },
            ),
          ),
        ),
      ),
    );
  }
}
